//Date Object Prototype by Steven Huang 2012/7/19
Date.prototype.IsDate=function(){
	if(this.getTime()>0)return true;
	return false;
}
Date.prototype.DateAdd=function(flag,adds){
	if(this.IsDate()){
		switch(flag){
			case "Y":
				this.setYear(this.getFullYear()+adds*1);
				break;
			case "M":
				this.setMonth(this.getMonth()+adds*1);
				break;
			case "D":
				this.setDate(this.getDate()+adds*1);
				break;
			case "h":
				this.setHours(this.getHours()+adds*1);
				break;
			case "m":
				this.setMinutes(this.getMinutes()+adds*1);
				break;
			case "s":
				this.setSeconds(this.getSeconds()+adds*1);
				break;
			default:
		}
	}
	return this;
}
Date.prototype.DateFormat=function (flag){
	if(this.IsDate()){
		var OutputString=(flag+'').match(/[YMDhms]+/g)!=null?flag:"Y/M/D";
		OutputString=OutputString.replace(/Y+/g,this.getFullYear().toString())
		OutputString=OutputString.replace(/M+/g,(this.getMonth()+1).toString())
		OutputString=OutputString.replace(/D+/g,this.getDate().toString())
		OutputString=OutputString.replace(/h+/g,this.getHours().toString())
		OutputString=OutputString.replace(/m+/g,this.getMinutes().toString())
		OutputString=OutputString.replace(/s+/g,this.getSeconds().toString())
		return OutputString;
	}
	return "";
}
//Date Object Prototype End


//String Object Convert by Steven Huang 2012/7/18
function RegExpTest(value,pattern){
	var test=new RegExp(pattern,"gi")
	if(value.match(test)!=null)
		return value.match(test)
	else
		return '';
}
function IntConvert(value){
	return RegExpTest(value,"^\\d+$");
}
function FloatConvert(value,digit){
	return RegExpTest(value,"^\\d+(\\.?\\d{1,"+digit+"})?")
}
//String Object Convert end

//Taiwan ID Checker by Steven Huang 2012/7/19
function TaiwanIDChecker(s){
	if(Input.toUpperCase().match(/^[A-Z\d][A-D12]\d{8}$/gi)==null) return false;
	var c, n, i;
	var t="0123456789ABCDEFGHJKLMNPQRSTUVXYWZIO";
	c=Input.substring(0,1);
	c=t.indexOf(c.toUpperCase());
	if((Input.length!=10)||(c<0)) return false;
	n=parseInt(c/10)+c%10*9;
	for(i=1;i<9;i++)
		n=n+((parseInt(t.indexOf(Input.substring(i,i+1).toUpperCase()))%10)*(9-i));
	n=(10-(n%10))%10;
	if(n!=parseInt(Input.substring(9,10))) return false;
	return true;
}
//Taiwan ID Checker End